
import { Component, OnInit, Input } from '@angular/core';
import { TaskListService } from '../tasklist.service';
import { CommandDispatcherService } from './command-dispatcher-service';
@Component({
    selector: 'tasklist-menu',
    templateUrl: './tasklist-menu.component.html',
    styleUrls: ['./tasklist-menu.component.scss'],
    providers: [TaskListService, CommandDispatcherService]
})
export class TaskListMenuComponent implements OnInit {
    @Input()
    parentObj: any; //父组件
    @Input()
    parentCallback: any;//父组件回调
    @Input()
    selectedRecord: any; //选中行

    menus: any[] = [];
    constructor(
        private taskListService: TaskListService,
        private commandDispatcherService: CommandDispatcherService
    ) { }

    ngOnInit() { }

    loadTaskListMenu(taskListId, actDefId, pozBit, actId, systemUrl) {
        this.taskListService.loadTaskListMenu(taskListId, actDefId, pozBit, actId, systemUrl).subscribe(menus => this.menus = menus);
    }

    /** 点击操作项 */
    dispatcherCommand(event, command) {
        this.commandDispatcherService.dispatcher(
            command, //点击指令
            this.selectedRecord, //当前选中
            this.parentObj,  //父组件实例
            this.parentCallback //回调方法
        );
    }

}